package com.yh.supergo.manager.controller;

import com.yh.supergo.manager.service.GoodsDescService;
import com.yh.supergo.manager.service.GoodsService;
import com.yh.supergo.manager.service.ItemService;
import com.yh.supergo.pojo.Goods;
import com.yh.supergo.pojo.Goodsdesc;
import com.yh.supergo.pojo.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName GoodsController
 * @Description TODO
 * @Author 0715-YuHao
 * @Date 2020/11/21 10:23
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @Autowired
    private GoodsDescService goodsDescService;

    @Autowired
    private ItemService itemService;

    @GetMapping("/{goodsId}")
    public Goods getGoodsById(@PathVariable long goodsId) {
        return goodsService.findOne(goodsId);
    }
    @GetMapping("/desc/{goodsId}")
    public Goodsdesc getGoodsDescById(@PathVariable long goodsId) {
        return goodsDescService.findOne(goodsId);
    }
    @GetMapping("/item/{goodsId}")
    public List<Item> getItemList(@PathVariable long goodsId) {
        return itemService.skuList(goodsId);
    }
}
